﻿using BusinessLogic.BusinessEntity.Entities;

namespace BusinessLogic.Mappers.RemittanceAdvice.Mapping
{
	internal class RemittanceAdviceMapping : IMapping<BusinessEntity.Entities.RemittanceAdvice, DataControl.RA>
	{
		public BusinessEntity.Entities.RemittanceAdvice ToBE(DataControl.RA from)
		{
			var to = new BusinessEntity.Entities.RemittanceAdvice();

			to.Description = from.Description;
			to.ID = from.ID;
			to.Number = from.Number;
			to.TotalAmount = from.TotalAmount;
			to.IssueDate = from.ActDate;
			to.BillToPartyAccount = new Account {ID = from.BillToPartyAccountFk};
			to.PayerPartyAccount = new Account {ID = from.PayerPartyAccountFk};
			to.Currency = new BusinessEntity.Entities.Currency {ID = from.CurrencyFk};

			return to;
		}

		public DataControl.RA ToDTO(BusinessEntity.Entities.RemittanceAdvice from)
		{
			var to = new DataControl.RA();

			to.BillToPartyAccountFk = from.BillToPartyAccount.ID;
			to.CurrencyFk = from.Currency.ID;
			to.Description = from.Description;
			to.ID = from.ID;
			to.Number = from.Number;
			to.ActDate = from.IssueDate;
			to.PayerPartyAccountFk = from.PayerPartyAccount.ID;
			to.TotalAmount = from.TotalAmount;

			return to;
		}
	}
}